{% extends "showinfo/base.html" %}

{% block content %}


    <div class="form-group">
        <label class="col-lg-3 control-label">图片上传识别</label>

        <div class="col-lg-4">
            <input type="file" name="img" id="img" class="form-control"/>

        </div>
        <div class="col-lg-4">
            <button type="button" class="btn btn-primary" onclick="getdata()">上传</button>
        </div>
    </div>

<br /><br /><br /><br /><br /><br /><br />

    <div class="alert alert-success" role="alert" id="msg">


    </div>

    <script>
        function getdata() {
            var formData = new FormData();
            var totalFiles = document.getElementById("img").files.length;
            for (var i = 0; i < totalFiles; i++) {
                var file = document.getElementById("img").files[i];

                formData.append("img", file);
            }
            $.ajax({
                type: "POST",
                url: '{% url "getapis:OCRImage" %}',
                data: formData,
                dataType: 'json',
                contentType: false,
                processData: false,
                success: function (response) {
                    $("#msg").html(response.content);
                    console.log(response);
                    //alert(response.content);
                },
                error: function (error) {


                }
            });
        }
    </script>


{% endblock %}